﻿package mortal.game.view.task.view.render
{
    import com.mui.controls.*;
    import com.mui.core.*;
    import com.mui.display.*;
    import flash.display.*;
    import flash.events.*;
    import flash.text.*;
    import mortal.common.*;
    import mortal.common.global.*;
    import mortal.game.events.*;
    import mortal.game.mvc.*;
    import mortal.game.resource.*;
    import mortal.game.view.common.*;
    import mortal.game.view.task.data.*;
    import mortal.mvc.core.*;

    public class TaskItemCellrender extends GCellRenderer
    {
        private var _txtName:GTextFiled;
        private var _txtStatus:GTextFiled;
        private var _taskInfo:TaskInfo;
        private var _line:ScaleBitmap;

        public function TaskItemCellrender()
        {
            return;
        }// end function

        override protected function initSkin() : void
        {
            var _loc_1:* = new Bitmap();
            this.setStyle("downSkin", GlobalClass.getBitmap(ImagesConst.taskItemSelected));
            this.setStyle("overSkin", GlobalClass.getBitmap(ImagesConst.taskItemSelected));
            this.setStyle("upSkin", _loc_1);
            this.setStyle("selectedDownSkin", GlobalClass.getBitmap(ImagesConst.taskItemSelected));
            this.setStyle("selectedOverSkin", GlobalClass.getBitmap(ImagesConst.taskItemSelected));
            this.setStyle("selectedUpSkin", GlobalClass.getBitmap(ImagesConst.taskItemSelected));
            return;
        }// end function

        override public function set selected(param1:Boolean) : void
        {
            super.selected = param1;
            if (param1)
            {
                Dispatcher.dispatchEvent(new DataEvent(EventName.TaskMoudleViewTaskInfo, this._taskInfo));
            }
            return;
        }// end function

        override public function set data(param1:Object) : void
        {
            this._taskInfo = param1 as TaskInfo;
            this._txtName.text = this._taskInfo.getName(false);
            this._txtStatus.htmlText = this._taskInfo.getStatusName();
            return;
        }// end function

        override protected function createDisposedChildrenImpl() : void
        {
            super.createDisposedChildrenImpl();
            this.mouseChildren = true;
            this.mouseEnabled = true;
            this._txtName = UIFactory.gTextField("", 4, 0, 160, 20, this);
            var _loc_1:* = GlobalStyle.textFormatPutong;
            _loc_1.align = TextFormatAlign.RIGHT;
            this._txtStatus = UIFactory.gTextField("", 4, 0, 160, 20, this, _loc_1);
            this._line = UIFactory.bg(-2, 20, 185, 2, this, ImagesConst.SplitLine);
            this.configEventListener(MouseEvent.CLICK, this.clickMeHandler);
            return;
        }// end function

        public function clickMeHandler(event:MouseEvent) : void
        {
            Dispatcher.dispatchEvent(new DataEvent(EventName.TaskMoudleViewTaskInfo, this._taskInfo));
            return;
        }// end function

        override protected function disposeImpl(param1:Boolean = true) : void
        {
            super.disposeImpl(param1);
            this._txtName.dispose(param1);
            this._txtName = null;
            this._line.dispose(param1);
            this._line = null;
            this._txtStatus.dispose(param1);
            this._txtStatus = null;
            return;
        }// end function

        override public function set label(param1:String) : void
        {
            return;
        }// end function

    }
}
